﻿package {
	import flash.events.MouseEvent;
	import flash.display.MovieClip;
	import flash.events.Event;

	import com.demonsters.debugger.MonsterDebugger;

	import flash.display.Sprite;

	[SWF(backgroundColor="#FFFFFF", frameRate="31", width="640", height="480")]
	public class Main extends MovieClip {
		private var test:Test;

		public function Main() {
			addEventListener(Event.ADDED_TO_STAGE, addedToStage);
			// changed
		}

		private function addedToStage(event:Event):void {
			removeEventListener(Event.ADDED_TO_STAGE, addedToStage);

			MonsterDebugger.initialize(this);
			MonsterDebugger.trace(this, "1111111111111");

			var s:Sprite = new Sprite();
			s.graphics.beginFill(0xff0000, 1);
			s.graphics.drawRect(100, 100, 100, 100);
			s.graphics.endFill();
			addChild(s);

			s.addEventListener(MouseEvent.CLICK, listener);

			test = new Test();
			test.init();
			addChild(test);
		}

		private function listener(event:MouseEvent):void {
			//removeChild(test);
			//test = null;
			MonsterDebugger.trace(this, "ok");
		}
	}
}
